

const {
    Schema,
    model
} = require('mongoose');
const moment = require("moment")

const carsSchema = new Schema({
    number: String,//车牌号
    //车主id
    ownerId: {
        type: Schema.Types.ObjectId,
        ref: 'Users'
    },
    status: String,//审核: check,待出租：wait，已出租： rented，下架：hide,
    price: Number,
    carImg: String,
    disable: {
        type: String,
        default: '1'
    },//代表车的禁用状态  0代表禁用，1代表可用（默认）
    rendtime: String,//出租时间
    brand: String,//车辆品牌
    info: String,//车辆描述信息
    praiseCount: [{
        type: Schema.Types.ObjectId,
        ref: 'Orders'
    }],//好评数，订单id
    mediumCount: [{
        type: Schema.Types.ObjectId,
        ref: 'Orders'
    }],//中评数
    badCount: [{
        type: Schema.Types.ObjectId,
        ref: 'Orders'
    }],//差评评数
    phone: String,
    stars: {
        type: String,
        default: '005'//默认五星好评
    },
    onTime: {
        type: String,//车辆上架时间
        default: moment().format('YYYY年MM月DD日')
    },
    downTime: {
        type: String,//车辆下架时间
        default: moment().format('YYYY年MM月DD日')
    },
}, {
    versionKey: false
});



const Cars = model('Cars', carsSchema, 'cars');

module.exports.Cars = Cars;